#include "app_message.h"
#include "app_common.h"
#include "log/log.h"
#include <string.h>
int main(int argc, char const *argv[])
{
    /* 1. 将json格式字符串转换为字符数组 */

    char *jsonStr = "{\"conn_type\":1,\"id\":\"5858\",\"msg\":\"61626364\"}";

    char str[256] = {0};

    if (app_message_json2chars(jsonStr, str) != SUCCESS)
    {
        log_error("app_message_json2chars failed");
    }
    for (int i = 0; i < strlen(str); i++)
    {
        printf("buff[%d] = %02x\n", i, str[i]);
    }

    /* 2. 将字符数组转换为json字符串 */

    char json[128] = {0};
    if (app_message_chars2json(str, json) != SUCCESS)
    {
        log_error("app_message_chars2json failed");
    }
    printf("json = %s \n", json);

    return 0;
}
